package com.toy.core.service;

import java.util.List;

import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Update;

import com.toy.core.dao.support.Page;
import com.toy.core.domain.BaseObject;
import com.toy.core.service.support.GridFSDBFileWrapper;

public interface BaseManager<T extends BaseObject>{
	
	/*---------------------save方法---------------------*/
	public T saveOrUpdate(T entity);
	
	public T updateById(Long id,String propertyName,Object newValue);
	
	public T findAndModify(long idValue,Update update);
	
	/*---------------------删除方法---------------------*/
	public void delete(Long id);
	
	public void delete(T entity);
	
	/*---------------------get方法---------------------*/
	public T getById(Long id);
	
	public T getUniqueByProperty(String propertyName,Object value);
	
	/*---------------------find方法---------------------*/
	public List<T> findByProperty(String propertyName,Object value);
	
	/*----------------------翻页方法--------------------*/
	public Page<T> findPaged(int pageNo, int pageSize);
	
	public Page<T> findPaged(List<Criteria> criterions, String orderBy,boolean isAsc,int pageNo, int pageSize);
	
	/*----------------------gridFS操作方法--------------------*/
	public GridFSDBFileWrapper getGridFSDBFileByObjectId(String objectId) throws Exception;
}
